package java.com.ktjy.text;

import com.ktjy.proxy.InterMediaryImpl;
import java.com.ktjy.proxy.IntermediaryCglibProxyFactory;
import com.ktjy.proxy.IntermediarySubclass;
import com.ktjy.service.Buyer;
import com.ktjy.service.impl.RealBuyer;
import org.apache.log4j.Logger;
import org.junit.Test;

public class BuyerTest {
    private Logger logger = Logger.getLogger(BuyerTest.class);
    @Test
    public void havealokkImpl() throws Exception{
//        Buyer buyer = new InterMediaryImpl(new RealBuyer());
        RealBuyer buyer = new IntermediarySubclass();
        String result = buyer.havealook();
        logger.info(result);
    }

    @Test
    public void havealookJdkProxy() throws Exception{
        Buyer buyer = new InterMediaryImpl(new RealBuyer());
        String result = buyer.havealook();
        logger.info(result);
    }

    @Test
    public void havealookCglibProxy() throws Exception{
        RealBuyer buyer = IntermediaryCglibProxyFactory.create(RealBuyer.class);
        String result = buyer.havealook();
        logger.info(result);
    }
}
